<template>
    <div class="iframe">
        <div class="i-title">
            <h3>组件B</h3>
        </div>
        <div class="i-tip">
            {{ info.name }},{{info.age}}
        </div>
        <div class="i-tip">
            <el-button @click="send">发送</el-button>
        </div>
    </div>
</template>
<script>
import { reactive,onMounted } from "vue";
import pubsub  from "pubsub-js"
export default {
    setup(){
       let info=reactive({
           name:"今天的天气很好",
           age:0
       })
       onMounted(()=>{
           pubsub.subscribe("Age",(prop,data)=>{
               info.age = data;
           })
       })
       function send(){
          // 发布
          pubsub.publish("getName",info.name)
       }
       return {
           info,
           send
       }
    }
}
</script>
